package com.node.tools.job;

import com.node.tools.service.ISecondNodeService;
import com.node.tools.service.impl.SecondNodeServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;

/**
 * @Created IntelliJ IDEA.
 * @Author XYoK
 * @PackageName com.node.tools.job
 * @Description 调用码云提供接口,进行单个产品多个标识的注册与解析
 * @Setting Editor | File and Code Templates.
 */
@Component
@RestController
public class TimerTask {

    private static Logger logger = LoggerFactory.getLogger(TimerTask.class);

    @Autowired
    private ISecondNodeService secondNodeService;

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /***
     * 定时任务主动获取数据
     * @return
     * @throws Exception
     */
    @Scheduled(cron = "${spring.cron}")
    public void batchSelectCron()throws Exception{
        logger.info("执行定时任务开始" + df.format(System.currentTimeMillis()));
        secondNodeService.saveData();
        logger.info("执行定时任务结束" + df.format(System.currentTimeMillis()));
    }

}
